
package org.wing.mouseListener;

import org.come.until.CutButtonImage;
import org.wing.panel.LHMainPanel;
import org.wing.panel.LHMainPanel;

import javax.swing.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class LHChooseRefiningCheckboxMouseListener extends MouseAdapter {
    private int p;
    private LHMainPanel LHMainPanel;

    public LHChooseRefiningCheckboxMouseListener(int p, LHMainPanel LHMainPanel) {
        this.p = p;
        this.LHMainPanel = LHMainPanel;
    }

    public void mousePressed(MouseEvent e) {
        int num = 0;

        int refiningMoney;
        for(refiningMoney = 0; refiningMoney < this.LHMainPanel.getWingRefiningType().length; ++refiningMoney) {
            if (this.LHMainPanel.getWingRefiningType()[refiningMoney]) {
                ++num;
            }
        }

        if (this.LHMainPanel.getWingRefiningType()[this.p]) {
            this.LHMainPanel.getWingRefining()[this.p].setIcon((Icon)null);
            --num;
        } else {
            if (num >= 3) {
                return;
            }

            this.LHMainPanel.getWingRefining()[this.p].setIcon(CutButtonImage.getImage("img/xy2uiimg/showjadesuit.png", 15, 15));
            ++num;
        }

        refiningMoney = this.LHMainPanel.getRefiningMoney(num);
        this.LHMainPanel.getRefiningTitle().setText("当前锁定花费仙玉为：" + refiningMoney + "仙玉");
        this.LHMainPanel.getWingRefiningType()[this.p] = !this.LHMainPanel.getWingRefiningType()[this.p];//设置锁
    }
}
